package com.gucheng.springframework.beans.factory.support;

import com.gucheng.springframework.beans.factory.config.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {

    //存储单例Bean
    private Map<String,Object> stringObjects = new HashMap<>();


    //获取指定名称的单例bean
    @Override
    public Object getSingleton(String beanName) {
        return stringObjects.get(beanName);
    }

    //注册单例Bean
    protected void addSingleton(String beanName,Object singletonObject){
        stringObjects.put(beanName,singletonObject);
    }
}
